<template>
	<div style="height: 100%;">
		<!--<div class="payList">
    <ul>
      <li>
        <span class="right">{{orderInfo.amt}}元</span> 消费总金额
      </li>
      <li>
        <span class="right">{{orderInfo.noSlae}}元</span> 不参与优惠金额
      </li>
      <li>
        <span class="right">{{orderInfo.deskNum}}</span> 桌号
      </li>
    </ul>
  </div>-->
		<div v-if="$route.query.inputAmt" class="gohome" @click="$router.push({name:'home'})"></div>
		<div class="adressInfo whiteBg">
			<p><span>消费总金额：</span><input onkeyup="value=value.replace(/[^\d\.]/g,'')" onkeypress="if((event.keyCode<48 || event.keyCode>57) && event.keyCode!=46 || /\.\d\d$/.test(value))event.returnValue=false" @keyup="keydownInputAmt" type="text" placeholder="询问店员后输入(必填)" v-model="inputAmt" /></p>
			<p><span>不参与优惠金额：</span><input onkeyup="value=value.replace(/[^\d\.]/g,'')" onkeypress="if((event.keyCode<48 || event.keyCode>57) && event.keyCode!=46 || /\.\d\d$/.test(value))event.returnValue=false" @keyup="keydownInputNoSlae" type="text" placeholder="询问店员后输入" v-model="inputNoSlae"></p>
			<p><span>桌号：</span><input type="text" placeholder="询问店员后输入" v-model="inputDeskNum"></p>

		</div>
		<div class="payCenter" v-if='shiyong&&inputAmt!=0'>
			<div class="payTit">
				可以使用的优惠券
			</div>
			<div class="payCouponList">

				<ul>
					<li v-for="(item, index) in bestC" :key="index">
						<div class="payBoxTop">
							<ul>
								<li>
									<p v-if="!$route.query.couponParam" class="aaa" @click="useCheck(index)">
										<i style="color: gray;" class="iconfont icon-02-copy"></i>
									</p>
									<p v-else class="aaa" @click="useCheck_2(index)">
										<i v-if="isChecked" style="color: red;" class="iconfont icon-checked"></i>
										<i v-if="!isChecked" style="color: gray;" class="iconfont icon-02-copy"></i>
									</p>
									<div>
										<div v-if="item.type" class="couponDiv" :class="{'coupon_yellow':item.type=='cash','coupon_green':item.type=='rebate','coupon_blue':item.type=='voucher','coupon_orange':item.type=='present','coupon_purple':item.type=='ticket'}">
											<div class="_num" :class="{'coupon_color_y':item.type=='cash','coupon_color_g':item.type=='rebate','coupon_color_b':item.type=='voucher','coupon_color_o':item.type=='present','coupon_color_p':item.type=='ticket'}">Coupon</div>
											<div class="_num_price">
												<coupon-num :num="item.denomination" :type="item.type"></coupon-num>
											</div>
											<div class="coupon_type">{{item.type | couponTp}}</div>
										</div>
										<div class="card_info">
											<div v-if="!$route.query.couponParam" class="card_name">
												{{item.name}}
											</div>
											<div v-if='$route.query.couponParam' class="card_name">
												{{item.couponName}}
											</div>
											<div class="coupon_info_item">
												<star :couponComScore="item.comScore"></star>
												<p class="info_pad">{{item.comNum}}条 &nbsp;&nbsp;&nbsp;&nbsp;{{item.type | couponTp}}<b v-if="!$route.query.couponParam" class="red_color"> {{item.num}} </b><b v-if="$route.query.couponParam" class="red_color"> {{nums}} </b>张</p>
											</div>
											<div class="clear"></div>
											<div class="coupon_info_item color_gray" style="margin-top: 0.3rem;">
												<img v-if="item.promAppro=='buy'" style="width: 1rem;height:1rem;z-index: 4;" src="../../images/cashIcon.png" />
												<img v-if="item.couponTypes=='third'" style="width: 1rem;height:1rem;z-index: 4;" src="../../images/dui.png" />
												<span>已售出  &nbsp;&nbsp;{{item.soldnum}}  &nbsp;已使用  &nbsp;&nbsp;{{item.usednum}}</span>
											</div>
										</div>
									</div>
								</li>
							</ul>
						</div>
						<img src="../../images/payCoupon.png">
						<div class="payBoxBot" @click="goCouponDetl(item)">
							<i class="icon iconfont icon-right right" style="font-size: 16px;"></i> 使用须知
						</div>
						<div class="iconBox" :class="{grayTxt:item.num==0}">
							<i class="iconfont icon-zengjia-" @click="countEvent('add',index)"></i>
							<span class="pay_coupon_num">{{item.num}}</span>
							<i class="iconfont icon-jianshao-" @click="countEvent('minus',index)"></i>
						</div>
					</li>
				</ul>
			</div>
		</div>
		<!--卡包无此订单的优惠券-->
		<template>
			<!--商户优惠信息-->
			<div class='mactActively' v-if="actShow||(inputAmt==0&&!tuijian)">
				<div class="tagtitle" v-if="!noAct&&activityList.length>0"><img src="../../images/MactActively_02.png" /></div>
				<div class="activeTit" v-if="!noAct&&activityList.length>0">活动说明</div>
				<div class='activeItem' v-for="couponItem in activityList">
					<div class="coupon_act_coupon">
						<div class="tagImage"><img src="../../images/MactActively.png" /></div>
						<!-- <card-img class="cardImage" :item="couponItem.coupon"></card-img> -->
						<div class="couponDiv">
							<coupon-denomination :item="couponItem.coupon"></coupon-denomination>
						</div>
						<div class="card_info_actively">
							<div class="card_infoup">
								<p class="card_name">{{couponItem.act.actName}}</p>
								<span class="card_price">面值：{{couponItem.coupon.denomination | denomination(couponItem.coupon.type || couponItem.coupon.couponType)}}</span>
							</div>
							<p class="activeDes">{{couponItem.act.actDsc}}</p>
						</div>
					</div>
				</div>
				<div class="noAct" v-if="noAct">此商户没有相关活动</div>
			</div>
			<!--推荐优惠券-->
			<div class="buyCoupon" v-if="tuijian&&inputAmt!=0&&(inputAmt!=inputNoSlae)">
				<div class="buyCouponTit">为你推荐优惠券</div>
				<coupon-card :coupon="coupon" v-for="(coupon,index) in recomCouList" :key='index' view="coupon" @exchange="exchange" :scanState="scanState" :tlrNo='tlrNo' :inputAmt='inputAmt' :inputNoSlae='inputNoSlae' :inputDeskNum='inputDeskNum'></coupon-card>
			</div>
		</template>

		<!--详细-->
		<!--<div class="payShaw" v-show="false">
    <div class="payDetail">
      <div class="payDetailT">订单号：{{$route.query.orderId}}</div>
      <div class="payDetailT2"><span class="right">共{{couponCount}}张电子券</span>已使用电子券</div>
      <div class="hasUseCou">
        <ul>
          <li>
            <div class="hasUseCouR">
            </div>
            <card-img :item="bestCBottom" type="small"></card-img>
            <div class="hasUseCouC">
              <span class="hasUseCouCT">{{bestCBottom.name}}</span>
              <span class="zhangshu">使用：{{bestCBottom.num}}张</span>
            </div>
          </li>
        </ul>
      </div>
    </div>
  </div>-->
		<div style="height: 3rem;"></div>
		<div class="payBtn" :class="{payBtnBg:!isChecked}">
			<div class="payEvent" :class="{'disabledBtn':payDisable}" @click="payEvent">立即买单</div>
			<div @click="payDetailE">
				<icon icon-name="#icon-qiabaomaidan-"></icon>
				<div class="payInfo">
					<p class="payMoney">{{payNum | formatMoney}}元</p>
					<p class="payCoupon" v-if='isChecked'>使用优惠券</p>
				</div>
			</div>
		</div>

		<!-- 购买弹框-->
		<exchange-box v-if="exchageShow" :param="couParams" :exchageShow="exchageShow" @hiddenExc="hiddenExc"></exchange-box>
		<!-- 奖励显示弹框 -->
		<!-- <reward-modal v-if="shareInfo" @close="hiddenShareInfo" :money="usrAmt" type="use" returnHistory='true'></reward-modal> -->
	</div>
</template>
<script>
	import RewardModal from 'src/componentes/global/reward/index.vue'
	import exchangeBox from 'src/componentes/global/exchangeBox.vue'
	import couponNum from '../../componentes/global/couponNum.vue'
	import star from '../../componentes/global/star.vue'
	import getData from '../../service/getData.js'
	import getData2 from '../../service/getData2.js'
	import * as types from '../../vuex/types.js'
	import CouponList from '../coupon/shareList/coupon.vue'
	import {
		Storage
	} from 'src/utils/storage.js'
	import {
		mapState
	} from 'vuex'
	import {
		Toast,
		Indicator,
		MessageBox
	} from 'mint-ui'
	export default {
		data: function() {
			return {
				activityList: [],
				showActList: true,
				noAct: false,
				bestC: [],
				storeC: [],
				couponCount: this.$route.query.couponParam ? 1 : 0,
				hasCoupon: false, //是否拥有代金券
				orderInfo: {},
				recommInfo: {},
				recomCouList: [], // 为你推荐电子券数量
				payDetail: false,
				tuijian: false,
				payNum: this.inputAmt,
				payDisable: false, //禁止按钮
				exchageShow: false, // 立即兑换弹框
				couParams: {},
				isChecked: false, //判断选券状态
				inputAmt: this.$route.query.inputAmt ||Storage.get('positiveScan',true)?Storage.get('positiveScan',true).inputAmt: '', //输入框1总金额
				inputNoSlae: this.$route.query.inputNoSlae ||Storage.get('positiveScan',true)?Storage.get('positiveScan',true).inputNoSlae: '', //输入框2不参加优惠金额
				inputDeskNum: this.$route.query.inputDeskNum ||Storage.get('positiveScan',true)?Storage.get('positiveScan',true).inputDeskNum: '', //输入框3桌号
				bestCBottom: "", //下方选券列表
				arr: [999, 999],
				currentIndex: '',
				status: true,
				yunNum: 0,
				nums: this.$route.query.couponParam ? this.$route.query.couponParam.num : 0, //现金券使用的电子券数量
				couNos: '', //卡包现金券使用的电子券码
				actShow: true,
				scanState: true,
				tlrNo: this.$route.query.t,
				// shareInfo: false, //奖励金
				// usrAmt: 0,
				orderId: '',
				shiyong: false
			}
		},
		components: {
			exchangeBox,
			couponNum,
			star,
			// cardImg,
			RewardModal
		},
		computed: {
			...mapState({
				userInfo: state => state.user.userInfo,
				couponPay: state => state.pay.couponPay,
				couponInfo: state => state.coupon.couponInfo, //优惠券数组
			})
		},
		watch: {
			//计算支付金额
			couponPay() {

				let me = this;
				if(this.couponPay) {
					//      this.getOrderInfo();
				}
				this.$store.commit("coupon_pay", false);
			}
		},
		methods: {
			getActList() {
				// 商户活动信息
				getData2.getPillActivity({
					method: 'post',
					data: {
						"aoData": "",
						"mchtId": this.$route.query.m,
						"money": 9999,
						"type": "pay"
					} //me.$route.params.mchtId/10000051
				}).then(rep => {
					if(rep.respCode = '00') {
						this.activityList = rep.content.list;
						if(!(rep.content.list) || rep.content.list.length == 0) {
							this.noAct = true;
						}
					}
				});
			},

			//获取芸券值(推荐电子券时用)
			getYunNum: function() {
				let me = this;
				getData.myAccount({}, me.userInfo.usrId).then(function(rep) {
					if(rep.respCode == '00') {
						me.yunNum = rep.content
						me.showActList = false;
						console.log(me.yunNum)
					}
				})
			},
			getRecomCou(data) {
				let that = this
				getData.recommendCoupon(data).then(rep => {
					if(rep.respCode == '00') {

						let list = rep.content.couponList || []
						if(list.length == 0) {
							//          this.getActList(this.orderInfo)
							that.recomCouList = []
							that.tuijian = false
							that.actShow = true
						} else {
							that.recomCouList = list
							console.log(that.recomCouList)
							if(that.recomCouList.length > 0) {
								that.tuijian = true
								that.actShow = false
							}
							that.recomCouList.forEach(item => {
								item.type = item.couponType
								item.name = item.couponName
								item.comNum = item.couponComNum
							})
						}
					}
				})
			},
			// 可以使用优惠券
			bestCoupon(data) {
				let me = this;
				getData.optionalCoupons({
					method: 'post',
					data: data
				}).then(rep => {
					me.bestC = rep.content.couponList;
					if(me.bestC.length > 0) {
						me.actShow = false
						me.shiyong = true
						me.tuijian = false
						me.recomCouList=[]

					} else {
						this.getRecomCou({
							method: 'post',
							data: {
								amt: me.inputAmt - me.inputNoSlae,
								mchtId: me.$route.query.m,
								noSlae: 0, // 无优惠金额
								page: 1,
								rows: 9999,
								usrId: me.userInfo.usrId,
								yunNum: me.yunNum
							}
						})
						me.shiyong = false
						me.actShow = true
					}
					me.bestC.forEach((item, index) => {
						item.isShare = false
					})

					me.storeC = JSON.parse(JSON.stringify(rep.content));

				})
			},
			payEvent: async function() {
				if(this.payNum < 0) {
					Toast({
						message: '支付金额输入有误！',
						duration: 1000
					});
				}
				if(this.inputAmt != '') {
					this.$store.commit('changeState', true)
					let me = this
					let couponId
					let coupons
					if(!this.$route.query.couponParam) {
						couponId = '' || this.bestCBottom.couponId
						coupons = couponId ? couponId + '+' + this.bestCBottom.couNo.split(',')[0] : ''
					} else {
						couponId = '' || this.bestCBottom[0].couponId
						coupons = couponId ? couponId + '+' + this.couNos : ''
					}
					let params = {
						method: 'post',
						data: {
							amt: me.inputAmt,
							couponAmt: ((me.inputAmt * 100 - me.payNum * 100) / 100).toFixed(2), // 电子券优惠金额
							coupons: coupons, // 电子劵id, 券码（id + 券码 + 券码, id + 券码 + 券码）
							deskNum: me.inputDeskNum,
							mchtId: me.$route.query.m || Storage.get("couponInfo").mchtId, // 商户号
							mchtName: "",
							noSlae: me.inputNoSlae == '' ? 0 : me.inputNoSlae,
							num: me.couponCount, // 使用电子券张数
							openId: me.userInfo.usrWchatOpenid, // 微信openId
							tlrNo: me.$route.query.t,
							trl: 'ebj', //交易渠道
							usrId: me.userInfo.usrId,
						}
					}
					let rep = await getData.positiveScanPay(params)

					if(rep.respCode == '00') {
						if(me.$route.query.couponParam){
										Storage.set("hasPayOrder", {
							usrId: me.userInfo.usrId,
							couponId: couponId,
//							couponNo: me.bestCBottom[0] ? `${me.bestCBottom[0].couponId}+${me.bestCBottom[0].couNo.split(",")[0]}` : '',
							orderId: rep.content.orderId,
							couponNoInfo: me.bestCBottom[0] ? {
								denomination: me.bestCBottom[0].denomination,
								type: me.bestCBottom[0].type
							} : '',
							num: me.couponCount || "",
							mchtId: me.$route.query.couponParam.mchtId,
							payNum: me.payNum,
							status: me.status, //是否选券
							market: 0 , //奖励金
							market2:0
						});
						}else{
										Storage.set("hasPayOrder", {
							usrId: me.userInfo.usrId,
							couponId: couponId,
							couponNo: me.bestCBottom ? `${me.bestCBottom.couponId}+${me.bestCBottom.couNo.split(",")[0]}` : '',
							orderId: rep.content.orderId,
							couponNoInfo: me.bestCBottom ? {
								denomination: me.bestCBottom.denomination,
								type: me.bestCBottom.type
							} : '',
							num: me.couponCount || "",
							mchtId: me.$route.query.m||me.$route.query.mchtId,
							payNum: me.payNum,
							status: me.status, //是否选券
							market: rep.content.market, //奖励金
							market2:rep.content.settUsrAmt
						});
						}

						// console.log(me.couponCount);
						if(Number(me.payNum) !== 0) {
							//        // 调用微信支付接口
							//        me.bridgeReady(data, me.orderInfo.orderId, params)
							let url = rep.content.payUrl || rep.content.data
		          location.href = url
						} else {
							me.orderId = rep.content.orderId
							// location.href = rep.content
							// if (rep.content.totalUsrAmt == 0) {
							me.lookState=true
							me.$router.replace({
								name: 'paySuccess',
								query: {
									orderId: rep.content.orderId,
									//                couponNo: me.couNos || me.bestCBottom.couNo,
									//                mchtId: me.$route.query.mchtId || Storage.get("couponInfo").mchtId
								}
							})
							// } else {
							//   this.usrAmt = rep.content.totalUsrAmt;
							//   this.shareInfo = true;
							// }

						}
					} else {
						Toast({
							message: rep.errorInfo,
							duration: 1000
						});
					}
				} else {
					Toast({
						message: '请填写完整！',
						duration: 1000
					});
				}

			},
			//查看使用电子券详情
			payDetailE() {
				this.payDetail = this.payDetail ? false : true;
			},

			//跳转详情
			goCouponDetl(params) {
				
				var me = this;
				Storage.set("couponInfo", params);
				me.lookState=true
				// this.$router.push({name:'couponDetail',query:{type:'noExchange'}});
				this.$router.push({
					name: 'couDetail',
					query: {
						type: 'noExchange',
						couponId: params.couponId,
						mchtId: params.mchtId,
						seq: params.seqNo || '',
						usrId: '',
						usrPicId: ''
					}
				});
			},
			exchange(params) {				
				this.exchageShow = true
				this.couParams = params
			},
			hiddenExc() {
				this.exchageShow = false
			},
			useCheck: async function(index) {
				if(this.bestC[index].couNo == '') {
					Toast({
						message: "该电子券在'我的订单'已绑定，如果使用请提前取消订单",
						duration: 1000
					});
					return
				}
				this.isChecked = this.isChecked ? false : true;
				this.couponCount = this.couponCount ? 0 : 1
				if(this.status) {
					//第一次选择
					this.arr.shift()
					this.arr.push(index)
					this.status = false;
					this.bestC.forEach((item, index) => {
						item.isShare = false
					})
					this.bestC[index].isShare = true
					console.log(this.bestC)
					document.getElementsByClassName("aaa")[index].children[0].style.color = 'red'
					document.getElementsByClassName("aaa")[index].children[0].className = ' iconfont icon-checked'
					this.isChecked = true
					this.bestCBottom = this.bestC[index]
					if(this.bestCBottom.type === 'rebate') {
						//        this.payNum = this.bestCBottom.denomination / 100 * (this.inputAmt - this.inputNoSlae) + Number(this.inputNoSlae)
						this.payNum = ((this.inputAmt * 100 - this.inputNoSlae * 100) * this.bestCBottom.denomination / 100 + this.inputNoSlae * 100) / 100

					} else {
						this.payNum = (this.inputAmt * 1000 - Number(this.bestCBottom.denomination) * 1000) / 1000

					}
					Storage.set('fukuan',{inputAmt:this.inputAmt,inputNoSlae:this.inputNoSlae},true)
				} else {
					this.status = true;
					this.arr.shift()
					this.arr.push(index)
					if(this.arr[0] == this.arr[1]) {
						//判断一个按钮按两下
						this.bestC.forEach((item, index) => {
							item.isShare = false
						})
						console.log(this.bestC)
						document.getElementsByClassName("aaa")[index].children[0].style.color = 'gray'
						document.getElementsByClassName("aaa")[index].children[0].className = 'iconfont icon-02-copy'
						this.isChecked = false
						this.bestCBottom = ''
						this.payNum = this.inputAmt
					} else {
						//选择其他的
						this.status = false;
						this.bestC.forEach((item, index) => {
							item.isShare = false
						})
						for(var i = 0; i < this.bestC.length; i++) {
							document.getElementsByClassName("aaa")[i].children[0].style.color = 'gray'
							document.getElementsByClassName("aaa")[i].children[0].className = 'iconfont icon-02-copy'
							this.isChecked = false
							this.bestCBottom = ''

						}
						this.bestC[index].isShare = true
						console.log(this.bestC)
						document.getElementsByClassName("aaa")[index].children[0].style.color = 'red'
						document.getElementsByClassName("aaa")[index].children[0].className = ' iconfont icon-checked'
						this.isChecked = true
						this.bestCBottom = this.bestC[index]
						if(this.bestCBottom.type === 'rebate') {
							//          this.payNum = this.bestCBottom.denomination / 100 * (this.inputAmt - this.inputNoSlae) + Number(this.inputNoSlae)
							this.payNum = ((this.inputAmt * 100 - this.inputNoSlae * 100) * this.bestCBottom.denomination / 100 + this.inputNoSlae * 100) / 100
						} else {
							this.payNum = (this.inputAmt * 1000 - Number(this.bestCBottom.denomination) * 1000) / 1000
						}
					}
				}
			},
			keydownInputAmt() {
				if(this.inputAmt!=0){
					if(this.isChecked){
					Toast({
						message: '输入时，请不要勾选电子券',
						duration: 1000
					});
					this.inputAmt=Storage.get('fukuan',true).inputAmt
				}
				if(this.payNum < this.inputNoSlae) {
					this.inputNoSlae = ''
				}
				if(!this.$route.query.couponParam && this.isChecked) {
					if(this.bestCBottom.type === 'rebate') {

						//        this.payNum = this.bestCBottom.denomination / 100 * (this.inputAmt - this.inputNoSlae) + Number(this.inputNoSlae)
						this.payNum = ((this.inputAmt * 100 - this.inputNoSlae * 100) * this.bestCBottom.denomination / 100 + this.inputNoSlae * 100) / 100
					} else {
						this.payNum = (this.inputAmt * 1000 - Number(this.bestCBottom.denomination) * 1000) / 1000
					}

				} else if(!this.$route.query.couponParam && !this.isChecked) {
					this.payNum = this.inputAmt

					this.bestCoupon({
						aoData: '',
						orderAmount: this.inputAmt - this.inputNoSlae,
						mchtId: this.$route.query.m,
						usrId: this.userInfo.usrId,
						amt:this.inputAmt
					});
				}
				//使用现金券勾选券时候
				if(this.$route.query.couponParam && this.isChecked) {

					if(this.bestCBottom[0].type === 'rebate') {

						//        this.payNum = this.bestCBottom[0].denomination / 100 * (this.inputAmt - this.inputNoSlae) + Number(this.inputNoSlae)
						this.payNum = ((this.inputAmt * 100 - this.inputNoSlae * 100) * this.bestCBottom[0].denomination / 100 + this.inputNoSlae * 100) / 100
					} else {
						this.payNum = (this.inputAmt * 1000 - Number(this.bestCBottom[0].denomination) * 1000) / 1000
					}
					if(this.payNum < 0) {
						this.isChecked = false
						this.payNum = 0
					}
				} else if(this.$route.query.couponParam && !this.isChecked) {
					this.payNum = this.inputAmt
				}
				}else{
					this.payNum = 0
				}
				

			},
			keydownInputNoSlae() {
				if(this.isChecked){
					Toast({
						message: '输入时，请不要勾选电子券',
						duration: 1000
					});
					this.inputNoSlae=Storage.get('fukuan',true).inputNoSlae
				}
				if(Number(this.inputAmt) < Number(this.inputNoSlae)) {
					Toast({
						message: '优惠金额不能大于消费总金额',
						duration: 1000
					});
					this.inputNoSlae = ''

				}
				//使用现金券勾选券时候
				if(this.$route.query.couponParam && this.isChecked) {
					if(this.bestCBottom[0].type === 'rebate') {
						this.payNum = ((this.inputAmt * 100 - this.inputNoSlae * 100) * this.bestCBottom[0].denomination / 100 + this.inputNoSlae * 100) / 100
						//        this.payNum = this.bestCBottom[0].denomination / 100 * (this.inputAmt - this.inputNoSlae) + Number(this.inputNoSlae)
					} else if((this.inputAmt - this.inputNoSlae) > this.bestCBottom[0].denomination) {
						this.payNum = (this.inputAmt * 1000 - Number(this.bestCBottom[0].denomination) * 1000) / 1000
						//        this.payNum = this.inputAmt - Number(this.bestCBottom[0].denomination)
					} else if((this.inputAmt - this.inputNoSlae) < this.bestCBottom[0].denomination) {
						this.isChecked = false
						this.inputNoSlae = ''
						this.payNum = this.inputAmt
					}
					//使用现金券没有勾选券时候
				} else if(this.$route.query.couponParam && !this.isChecked) {
					this.payNum = this.inputAmt
				}
				////////////////////////////////////////////////////////////////////////
				if(!this.$route.query.couponParam && !this.isChecked&&this.inputNoSlae!=this.inputAmt) {
					this.bestCoupon({
						aoData: '',
						orderAmount: this.inputAmt - this.inputNoSlae,
						mchtId: this.$route.query.m,
						usrId: this.userInfo.usrId,
						amt:this.inputAmt
					});

				} else if(!this.$route.query.couponParam && !this.isChecked&&this.inputNoSlae==this.inputAmt){
					this.shiyong=false
					this.actShow=true
					this.getActList()

				} else if(!this.$route.query.couponParam && this.isChecked) {

					if(this.bestCBottom.type === 'rebate') {

						//        this.payNum = this.bestCBottom.denomination / 100 * (this.inputAmt - this.inputNoSlae) + Number(this.inputNoSlae)
						this.payNum = ((this.inputAmt * 100 - this.inputNoSlae * 100) * this.bestCBottom.denomination / 100 + this.inputNoSlae * 100) / 100
					} else if((this.inputAmt - this.inputNoSlae) > this.bestCBottom.denomination) {
						this.payNum = (this.inputAmt * 1000 - Number(this.bestCBottom.denomination) * 1000) / 1000
					} else if((this.inputAmt - this.inputNoSlae) < this.bestCBottom.denomination) {
						this.isChecked = false
						this.shiyong = false
						this.inputNoSlae = ''
						this.payNum = this.inputAmt
						return
					}
					//使用现金券没有勾选券时候

				}

			},
			useCheck_2() {
				if(this.bestCBottom[0].couNo == '') {
					Toast({
						message: "该电子券在'我的订单'已绑定，如果使用请提前取消订单",
						duration: 1000
					});
					return
				}
				if((this.inputAmt - this.inputNoSlae) < Number(this.bestCBottom[0].denomination)) {
					Toast({
						message: '消费总金额与不参与优惠金额输入不符合该电子券的使用规则',
						duration: 1000
					});
					return
				}

				this.isChecked = this.isChecked ? false : true;
				this.couponCount = this.couponCount ? 0 : 1
				if(this.isChecked) {
					this.status = true
					if(this.bestCBottom[0].type === 'rebate') {

						//        this.payNum = this.bestCBottom[0].denomination / 100 * (this.inputAmt - this.inputNoSlae) + Number(this.inputNoSlae)
						this.payNum = ((this.inputAmt * 100 - this.inputNoSlae * 100) * this.bestCBottom[0].denomination / 100 + this.inputNoSlae * 100) / 100
					} else {
						this.payNum = (this.inputAmt * 1000 - Number(this.bestCBottom[0].denomination) * 1000) / 1000
					}
				} else {
					this.status = false
					this.payNum = this.inputAmt

				}
			},
			hiddenShareInfo() {
				let me = this;
				me.lookState=true
				me.$router.replace({
					name: 'paySuccess',
					query: {
						orderId: me.orderId,
						//        couponNo: me.couNos || me.bestCBottom.couNo,
						//        mchtId: me.$route.query.mchtId || Storage.get("couponInfo").mchtId
					}
				})
				me.shareInfo = false;
			},
		},
		created: function() {
			this.$emit('header-info', {
				title: '付款详情',
				isBack: true,
				isMessage: false
			})
			//获取订单信息
			//  this.getOrderInfo();



		},
		mounted: async function() {
				if(this.$route.query.couponParam) {
				this.bestC.push(this.$route.query.couponParam)
				this.bestCBottom = this.bestC
				this.shiyong = true
				this.actShow = false
			}
			if(Storage.get('couponInfo')) {
				this.num = Storage.get('couponInfo').num
			}

			if(this.$route.query.inputAmt||Storage.get('positiveScan',true)) {
				this.bestCoupon({
					aoData: '',
					orderAmount: this.inputAmt - this.inputNoSlae,
					mchtId: this.$route.query.m,
					usrId: this.userInfo.usrId,
					amt:this.inputAmt
				});
				this.payNum = this.inputAmt
			}
			this.getActList()
			this.getYunNum()
			//关闭“订单查询中...”提示
			let me=this
			this.$nextTick(() => {
			});
			if(this.$route.query.couponParam) {
				let data = {
					method: 'post',
					data: {
						couponId: this.bestCBottom[0].couponId,
						mchtId: this.bestCBottom[0].mchtId,
						usrId: this.userInfo.usrId
					}
				}
				let code = await getData.findCode(data)
				if(code.respCode) {
					this.couNos = JSON.parse(code.content).couponNos.split(',')[0]
				}
			}
		},
	beforeRouteLeave(to, from, next){
		this.lookState=true
	Storage.remove('fukuan',true)
	Storage.set('positiveScan',{inputAmt:this.inputAmt,inputNoSlae:this.inputNoSlae,inputDeskNum:this.inputDeskNum,mchtId:this.$route.query.m},true)
    window.removeEventListener('scroll', this.handleScroll);
    
	if(window.isBack&&this.$route.query.gobuy){
  		window.isBack =false
  		this.$router.push({path:"/home"})
 }
    next()
 },
	}
</script>
<style scoped>
	.gohome {
		width: 5rem;
		height: 4rem;
		position: absolute;
		left: 0;
		top: 0;
		z-index: 88;
	}

	.payList li {
		border-bottom: 1px solid #f0f0f0;
		height: 3rem;
		line-height: 3rem;
		color: #666;
		padding: 0 .667rem;
		background: #fff;
		box-sizing: border-box;
		position: relative;
	}

	.payList li:last-child {
		border: none;
	}

	.payList li span {
		color: #333;
	}
	/*center*/

	.payCenter {
		background: linear-gradient(35deg, #ec4e8a, #f95a7c);
		min-height: 28rem;
	}

	.payTit {
		height: 3rem;
		line-height: 3rem;
		padding: 0 .667rem;
		color: #fff;
	}

	.payCouponList {
		padding: 0 .667rem;
	}

	.payCouponList li {
		margin-bottom: .667rem;
		position: relative;
		overflow: hidden;
	}

	.payCouponList li>img {
		width: 100%;
		display: block;
	}

	.payBoxTop {
		background: #fff;
		border-top-left-radius: .2rem;
		border-top-right-radius: .2rem;
		overflow: hidden;
		padding: 0.5rem .667rem 0;
	}

	.payBoxBot {
		min-height: 2rem;
		background: #fff;
		border-bottom-left-radius: .2rem;
		border-bottom-right-radius: .2rem;
		padding: 0 .667rem;
		font-size:1rem;
		color: #333;
		line-height: 1.6rem;
	}

	.payBoxBot .icon {
		color: #727272;
	}

	.payCouponList .move {
		-webkit-transform: translate(-4rem, 0);
		overflow: visible;
	}

	.iconBox {
		position: absolute;
		padding-left: .667rem;
		text-align: center;
		right: -4.667rem;
		top: 0;
		width: 4.667rem;
		background: #3f3f3f;
		height: 100%;
		z-index: -1;
		display: flex;
		justify-content: center;
		align-items: center;
		align-content: center;
		flex-direction: column;
	}

	.iconBox .iconfont {
		color: #ec4e8a;
		font-weight: bold;
		font-size: 1.2rem;
		display: block;
		margin: 0 auto;
	}

	.pay_coupon_num {
		display: block;
		font-size: 1.2rem;
		margin: 0 auto;
		color: #ec4e8a;
		height: 4rem;
		line-height: 4rem;
	}

	.grayTxt .pay_coupon_num,
	.grayTxt .icon-jianshao- {
		color: #999;
	}
	/*电子券推荐*/

	.buyCoupon {}

	.buyCouponTit {
		color: #333;
		height: 3rem;
		line-height: 3rem;
		padding: 0 .667rem;
		border-top: 1px solid #f0f0f0;
	}
	/*订单使用电子券详细*/

	.payShaw {
		position: fixed;
		top: 0;
		left: 0;
		right: 0;
		bottom: 4rem;
		background: rgba(0, 0, 0, .6);
	}

	.payDetail {
		position: absolute;
		bottom: 0;
		left: 0;
		width: 100%;
		min-height: 10rem;
		background: #fff;
	}

	.payDetailT {
		height: 3rem;
		line-height: 3rem;
		padding: 0 .667rem;
		border-bottom: 1px solid #f0f0f0;
		color: #333;
		font-weight: bold;
	}

	.payDetailT2 {
		height: 3rem;
		line-height: 3rem;
		padding: 0 .667rem;
		border-bottom: 1px solid #f0f0f0;
		color: #666;
		font-size: 1rem;
	}

	.hasUseCou {}

	.hasUseCou li {
		padding: .667rem;
		border-bottom: 1px solid #f0f0f0;
		overflow: hidden;
	}

	.hasUseCouC {
		flex: 1;
		padding: 0 0 0 .667rem;
		overflow: hidden;
	}

	.hasUseCouCT {
		display: block;
		color: #333;
		font-weight: bold;
		padding-top: .2rem;
	}

	.zhangshu {
		font-size: 1rem;
		color: #666;
		padding-top: .6rem;
		display: block;
	}

	.hasUseCouR {
		float: right;
		width: 5rem;
		display: flex;
		align-items: center;
		height: 4.2rem;
		justify-content: space-between;
	}

	.hasUseCouR .iconfont {
		color: #ec4e8a;
		font-size: 1.2rem;
		font-weight: bold;
	}
	/*按鈕*/

	.payBtn {
		position: fixed;
		bottom: 0;
		left: 0;
		right: 0;
		height: 4rem;
		background: #ffffff;
		box-shadow: 0 -.2rem 1rem rgba(0, 0, 0, .4);
		z-index: 99;
	}

	.payBtnBg {
		background: #333;
	}

	.payBtnBg .payMoney {
		color: #ec4e8a;
	}

	.payBtnBg .payCoupon {
		color: #939393;
	}

	.payBtn .icon {
		font-size: 2.8rem;
		float: left;
		margin: .6rem 0 0 .667rem;
	}

	.payInfo {
		float: left;
		line-height: 1.2rem;
		margin: .9rem 0 0 .6rem;
	}

	.payMoney {
		font-size: 1.2rem;
	}

	.payCoupon {
		font-size: .8rem;
	}

	.payEvent {
		float: right;
		height: 2.6rem;
		margin: .7rem .667rem 0 0;
		line-height: 2.6rem;
		background: linear-gradient(35deg, #ec4e8a, #f95a7c);
		padding: 0 2rem;
		font-size: 1.1rem;
		color: #fff;
		border-radius: .2rem;
	}

	.disabledBtn {
		background: #aaa;
	}

	.aaa {
		position: absolute;
		right: 1rem;
		top: 3rem;
	}
	/*商户活动*/

	.coupon_act_coupon {
		position: relative;
		overflow: hidden;
		padding: 1rem 0.667rem;
		height: 8rem;
		margin-top: 0.667rem;
		box-sizing: border-box;
		background-size: 100%;
		background-color: #fff;
		border-bottom: 1px solid #f0f0f0;
	}

	.coupon_act_coupon:first-child {
		margin-top: 0;
	}

	.activeDes {
		font-size: 0.8rem;
		color: #999;
		background: #fff;
		margin-top: .4rem;
	}

	.activeTit {
		font-size: 1.2rem;
		font-weight: bold;
		margin-top: .667rem;
		padding-top: 1rem;
		padding-bottom: .667rem;
		padding-left: 0.667rem;
		color: #333;
		background: #fff;
		border-bottom: 1px solid #f0f0f0;
	}

	.noAct {
		height: 8rem;
		font-size: 1rem;
		line-height: 8rem;
		color: #666;
		text-align: center;
	}

	.card_price {
		color: #666;
		line-height: 1.5rem;
	}

	.tagImage {
		position: absolute;
		left: .5rem;
		top: 1.4rem;
		z-index: 9;
	}

	.tagImage img {
		width: 2rem;
		height: 1.9rem;
	}

	.mactActively {
		position: relative;
	}

	.tagtitle {
		position: absolute;
		right: 1.068rem;
		top: -.4rem;
		z-index: 20;
	}

	.tagtitle img {
		width: 5.2rem;
		height: 5.2rem;
	}

	.card_info_actively {
		overflow: hidden;
		line-height: 1.86rem;
		padding: 0 .667rem
	}

	.card_infoup {
		border-bottom: 1px dashed #f0f0f0;
		padding-bottom: .4rem;
	}
	/*输入框*/

	.adressInfo p {
		height: 3.17rem;
		line-height: 3.17rem;
		padding: 0 1.5rem 0 1.5rem;
	}

	.adressInfo p span {
		position: absolute;
		left: 1.5rem;
		color: #333;
	}

	.adressInfo p input {
		float: right;
		text-align: right;
		height: 3rem;
		color: #666;
		font-size: 1rem;
	}

	i {
		font-size: 18px;
	}
</style>
